#!/bin/bash

# 启动数据库服务
# Start Database Services

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_ROOT"

echo "🚀 启动数据库服务..."
echo "📦 PostgreSQL (5432), MongoDB (27017), Redis (6379)"
echo ""

# 启动数据库容器
docker compose -f docker-compose.databases.yml up -d

echo ""
echo "⏳ 等待数据库服务健康检查..."
sleep 5

# 检查容器状态
docker compose -f docker-compose.databases.yml ps

echo ""
echo "✅ 数据库服务启动完成！"
echo ""
echo "📊 连接信息："
echo "  PostgreSQL: localhost:5432"
echo "    - 数据库: aipaper_db"
echo "    - 用户名: admin"
echo "    - 密码: newhand"
echo ""
echo "  MongoDB: localhost:27017"
echo "    - 数据库: ai_writing"
echo "    - 用户名: admin"
echo "    - 密码: newhand"
echo ""
echo "  Redis: localhost:6379"
echo "    - 密码: newhand"
echo ""
echo "💡 查看日志: docker compose -f docker-compose.databases.yml logs -f"
